<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false" import="java.util.*"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="chtml" uri="http://www.szhelper.com/jsp/html"%>
<script src="<%=request.getContextPath() %>/js/jquery-1.4.2.min.js"></script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>平台资金操作</title>

<script type="text/javascript">

function transferPlat2personSubmit()
{
var moeny=$("#plat2person_money").val();
var userName=$("#userName").val();
var outSubAccountId=$("#plat2person_outSubAccountId").val();
$.ajax({
type : "post",
url : "<%=request.getContextPath()%>/platform/transferPlat2Person",
data : {outSubAccountId:outSubAccountId,userName:userName,money:moeny},
			dataType : "json",
			async : false,
			success : function(jsonData) {
				if(!jsonData.isSuccess)
				{
					 alert(jsonData.message);
					 return ;
				}
				var direc_page = window.open("", "direc_page");
				direc_page.document
						.write(jsonData.returnValue.orderFormContent);
			},
			error : function(xMLHttpRequest, textStatus, errorThrown) {
				alert("请求出错！");
			}
		});
}

function transferPlat2PlatSubmit()
{
var moeny=$("#plat2plat_money").val();
var outSubAccountId=$("#plat2plat_outSubAccountId").val();
var inSubAccountId=$("#plat2plat_inSubAccountId").val();
$.ajax({
type : "post",
url : "<%=request.getContextPath()%>/platform/transferPlat2Plat",
data : {outSubAccountId:outSubAccountId,inSubAccountId:inSubAccountId,money:moeny},
			dataType : "json",
			async : false,
			success : function(jsonData) {
				if(!jsonData.isSuccess)
				{
					 alert(jsonData.message);
					 return ;
				}
				var direc_page = window.open("", "direc_page");
				direc_page.document
						.write(jsonData.returnValue.orderFormContent);
			},
			error : function(xMLHttpRequest, textStatus, errorThrown) {
				alert("请求出错！");
			}
		});
}
function paymentSubmit() {
	var money=$("#payment_money").val();
	var paymentType=$("#paymentType").val();
	if (money == null || money == "") {
		alert("请输入充值金额");
		return;
	}
	if (isNaN(money)) {
		alert("充值金额必须为数字");
		return;
	}
	$.ajax({
		type : "post",
		url : "<%=request.getContextPath()%>/platform/payment",
		data : {type:paymentType,money:money},
		dataType : "json",
		async : false,
		success : function(jsonData) {
			var direc_page = window.open("", "direc_page");
			direc_page.document.write(jsonData.returnValue.orderFormContent);
		},
		error : function(xMLHttpRequest, textStatus, errorThrown) {
			alert("请求出错！");
		}
	});
}
function addmoney() {
	
	var money=$("#add_money").val();
	var userName=$("#userName_add").val();
	var remark=$("#remark").val();
	if (userName == null || userName == "") {
		alert("请输入用户名");
		return;
	}
	if (money == null || money == "") {
		alert("请输入充值金额");
		return;
	}
	var reg = /^\+?(\d*\.\d{2})$/;
	if(!reg.test(money)){
		alert("金额必须2位小数的数字");
		return;
	}
	$.ajax({
		type : "post",
		url : "<%=request.getContextPath()%>/platform/addMoney",
		data : {userName:userName,money:money,remark:remark},
		dataType : "json",
		async : false,
		success : function(jsonData) {
			alert(jsonData.message);
			$("#add_money").val("");
			$("#userName_add").val("");
			$("#remark").val("");
		},
		error : function(xMLHttpRequest, textStatus, errorThrown) {
			alert("请求出错！");
		}
	});	
}
</script>
</head>
<body>
	<div class="youarehere">
		资金管理 &gt; <span>平台资金操作</span>
	</div>
	
	<div>
		<style type="text/css">
		.ty_table td{padding-left: 5px;padding-top: 5px; padding-bottom: 5px;}
		.ty_table .tr:hover{background: #ddd;}
		
		</style>
		<table border="1" cellpadding="5" cellspacing="1" bgcolor="#ddd" width="99%" class="ty_table">
		<tr style="background: #fff;line-height: 28px; font-weight: 700;" class="tr">
		<td>账户类型</td>
		<td>账户ID</td>
		<td>账户金额</td>
		<td>可用金额</td>
		<td>冻结金额</td>
		</tr>
		<c:if test="${not empty queryAccts}">
		<c:forEach items="${queryAccts.acctDetails}" var="acc">
		<tr style="background: #fff">
			<td>${acc.acctType }</td>
			<td>${acc.subAcctId }</td>
			<td>${acc.acctBal }</td>
			<td>${acc.avlBal }</td>
			<td>${acc.frzBal }</td>
		</tr>
		
		</c:forEach>
		</c:if>
		<table>
	</div>
	<c:set var="type" value="<%=com.hengpeng.itfinbase.persist.Partner.PartnerType.FUND%>"/>
	<c:if test="${partner.partnerType ne type}">
	<div>平台向用户转账</div>
	转出平台子账户：
	<chtml:enum name="plat2person_outSubAccountId" textProperty="accountName" valueProperty="subAccountId" itemsName="platAccList"/><br/>
	转入用户：<input type="text" name="userName" id="userName" placeholder="用户名"/>
	金额：<input type="text" name="plat2person_money" id="plat2person_money"/>
	<input type="button" value="提交" onclick="transferPlat2personSubmit()"/>
    <br/><br/>
	<div>平台子账户之间转账</div>
	转出平台子账户：
	<chtml:enum name="plat2plat_outSubAccountId" textProperty="accountName" valueProperty="subAccountId" itemsName="platAccList"/>
	<br/>
	转入平台子账户：
	<chtml:enum name="plat2plat_inSubAccountId" textProperty="accountName" valueProperty="subAccountId" itemsName="platAccList"/>
	<br/>
	金额：<input type="text" name="plat2plat_money" id="plat2plat_money"/>
	<input type="button" value="提交" onclick="transferPlat2PlatSubmit()"/>
	<br/><br/>
	<div>平台充值取现</div>
	<table>
		选择操作类型：<chtml:enum name="paymentType" defaultOption="--全部--" defaultValue="" selected="${requestScope.paymentType}" textProperty="text"
					type="com.hengpeng.itfinbase.persist.Payment$PaymentType" /><br/>
		金额：<input type="text" name="payment_money" id="payment_money"/>
	<input type="button" value="提交" onclick="paymentSubmit()"/>
	</table>	
    </c:if>
    <br/><br/>
    
    <!-- 
	<div>给用户账户加钱</div>
	<table>
		用户名：<input type="text" name="userName_add" id="userName_add" placeholder="用户名"/>	金额：<input type="text" name="add_money" id="add_money"/>(单位：元)
	&nbsp;&nbsp;&nbsp;	备注：&nbsp;<input type="text" name="remark" id="remark" placeholder="备注"/>
	&nbsp;&nbsp;&nbsp;<input type="button" value="提交" onclick="addmoney()"/>
	</table> -->

	<!--说明   -->
	<div class="sm_info">
		<p class="row_one">说明：</p>
		<p class="other"></p>
		<p class="other"></p>
	</div>
</body>
</html>